<style type="text/css">
    .bootstrap-datetimepicker-widget.dropdown-menu {
        inset: -10px -20px -30px -40px;
        z-index: 1051 !important;
    }
</style>
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    {:token()}
    <fieldset class="layui-elem-field">
        <legend>基本信息</legend>
        <div class="row layui-field-box">
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                <div class="form-group">
                    <label class="control-label col-xs-12 col-sm-2"><span
                            style="color:red;">*</span>{:__('Expense_code')}:</label>
                    <div class="col-xs-12 col-sm-8">
                        <input id="c-expense_code" data-rule="required" class="form-control" name="row[expense_code]"
                            type="text" readonly value="{$row.expense_code}">
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                <div class="form-group">
                    <label class="control-label col-xs-12 col-sm-2"><span
                            style="color:red;">*</span>{:__('Income_month')}:</label>
                    <div class="col-xs-12 col-sm-8">
                        <input id="c-income_month" data-rule="required" min="0" class="form-control datetimepicker"
                            data-date-format="YYYY-MM" name="row[income_month]" type="text" value="{$row.income_month_text}">
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                <div class="form-group">
                    <label class="control-label col-xs-12 col-sm-2"><span
                            style="color:red;">*</span>{:__('Start_time')}:</label>
                    <div class="col-xs-12 col-sm-8">
                        <input id="c-start_time" data-rule="required" min="0" class="form-control datetimepicker"
                            data-date-format="YYYY-MM-DD" data-use-current="true" name="row[start_time]" type="text"
                            value="{$row.start_time_text}">
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                <div class="form-group">
                    <label class="control-label col-xs-12 col-sm-2"><span
                            style="color:red;">*</span>{:__('End_time')}:</label>
                    <div class="col-xs-12 col-sm-8">
                        <input id="c-end_time" data-rule="required" class="form-control datetimepicker"
                            data-date-format="YYYY-MM-DD" data-use-current="true" name="row[end_time]" type="text"
                            value="{$row.end_time_text}">
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <div class="form-group">
                    <label class="control-label col-xs-12 col-sm-1">{:__('Remark')}:</label>
                    <div class="col-xs-12 col-sm-11">
                        <textarea id="c-remark" class="form-control" name="row[remark]" rows="5"
                            placeholder="{:__('Remark')}">{$row.remark}</textarea>
                    </div>
                    <!-- <div>最终报销金额元零元整</div> -->
                </div>
            </div>
        </div>
    </fieldset>
    <fieldset class="layui-elem-field">
        <legend>报销费用明细信息</legend>
        <div style="width: 100%; overflow-x: auto;">
            <table class="table table-responsive fieldlist" data-name="row[info]" data-template="infotpl" data-tag="tr">
                <tr>
                    {foreach name="fields" item="vo"}
                    <th>{if condition="$vo.name eq 'subject_matter' || $vo.name eq 'expense_time'"}<span
                            style="color:red;">*</span>{/if}{$vo.comment}</th>
                    {/foreach}
                    <td></td>
                </tr>
                <tr>
                    <td colspan="5"><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i
                                class="fa fa-plus"></i> 追加</a></td>
                </tr>
                <textarea name="row[info]" class="form-control hide" cols="30" rows="5">{$row.info}</textarea>
            </table>
            <div class="text-right" style="margin-top: 10px;">
                <h4 id="amount-in-words">合计报销金额：<span id="total_money" style="color:red;">{$row.cost}</span>元 <span id="total_money_chinese" style="color:red;">零元整</span></h4>
            </div>
        </div>
    </fieldset>
    <fieldset class="layui-elem-field">
        <legend>附件</legend>
        <div class="row layui-field-box">
            <div class="col-xs-12 col-sm-12">
                <div class="form-group col-sm-10">
                    <label class="control-label col-xs-12 col-sm-1">附件:</label>
                    <div class="input-group">
                        <input id="p-file_ids" class="form-control" placeholder="请上传" size="35" name="row[file_ids]"
                            type="text" value="{$row.file_ids}">
                        <div class="input-group-addon no-border no-padding">
                            <span><button type="button" class="btn btn-danger faupload" data-input-id="p-file_ids"
                                    data-url="kuerp/base/upload" data-ids="file_ids" data-multiple="true" data-preview-id="c-file_ids"><i
                                        class="fa fa-upload"></i> {:__('Upload')}</button></span>

                        </div>
                        <span class="msg-box n-rightdata-pagination "></span>
                    </div>
                    <ul class="row list-inline faupload-preview" id="c-file_ids" data-id="file_ids"></ul>
                </div>
            </div>
        </div>
    </fieldset>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-check_status" class="form-control" name="row[check_status]" type="hidden" value="{$row.check_status}">
            <button type="button" class="btn btn-info save" data-status="0">{:__('保存')}</button>
            <button type="button" class="btn btn-primary btn-embossed save" data-status="1">{:__('保存并提交审核')}</button>
            <!-- <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> -->
        </div>
    </div>
</form>

<script type="text/html" id="infotpl">
    <tr class="form-inline">
        <input type="hidden" name="row[info][<%=index%>][id]" value="<%=row['id']%>" />
        {foreach name="fields" item="vo"}
        <td>
            {if condition="$vo.name eq 'remarks' || $vo.name eq 'subject_matter' "}
            <textarea name="row[info][<%=index%>][{$vo.name}]" class="form-control" rows="2" placeholder="请输入" {if condition="$vo.name eq 'subject_matter'"}data-rule="required"{/if}><%=row["{$vo['name']}"]%></textarea>
            {elseif condition="$vo.name eq 'expense_time'"}
            <input style="width: 120px" class="form-control datetimepicker" data-rule="required" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[info][<%=index%>][{$vo.name}]" type="text" value="<%=row['expense_time_text']%>">
            {else /}
            <input style="width: 80px" {if condition="$vo.type eq 'int' || $vo.type eq 'bigint' || $vo.type eq 'double' || $vo.type eq 'decimal'"} type="number" min="0" step="0.01" class="form-control {if condition="$vo.name neq 'total_money'"}fee{/if}" value='<%=row["{$vo.name}"] ?? 0%>' {else /} type="text" class="form-control" value='<%=row["{$vo.name}"]%>' {/if} name="row[info][<%=index%>][{$vo.name}]"  {if condition="$vo.name eq 'total_money'"}readonly data-rule="required|digits|range(0~)"{/if}>
            {/if}
        </td>
        {/foreach}
        <td style="width: 80px"><span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span></td>
    </tr>
</script>